package com.itheima.health.controller;

import com.itheima.interfaces.SetmealService;
import com.itheima.pojo.Setmeal;
import com.itheima.resources.MessageConstant;
import com.itheima.resources.entity.Result;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 微信后端业务处理
 * 查
 */
@RequestMapping("setmeal")
@RestController
public class SetmealController {

    @Reference
    private SetmealService setmealService;

    @RequestMapping("findAllSetmeal.do")
    public Result findAllSetmeal() {

        try {
            List<Setmeal> list = setmealService.list();
            return new Result(true, MessageConstant.QUERY_SETMEALLIST_SUCCESS, list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEALLIST_FAIL);
        }
    }

    @RequestMapping("findSetMealDetail.do")
    public Result findSetMealDetail(@RequestParam("id") Integer id) {

        try {
            Setmeal setmeal = setmealService.findSetMealDetailBySetmealId(id);
            return new Result(true, MessageConstant.QUERY_ORDER_SUCCESS, setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_ORDER_FAIL);
        }
    }
}
